{% load form_helpers %}
{% load helpers %}

<div class="modal fade" tabindex="-1" id="{{ form_name }}_form">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">{{ form_name }}</h4>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body">
                <form class="form-horizontal userconfigform" data-config-root="forms.{{ form_as_dialog.form_name }}" action="{{ form_action_url }}" method="post">
                    {% csrf_token %}
                    <h3>
                        {% if obj %}
                            <a href="{{ obj|get_docs_url }}" target="_blank" class="btn btn-link btn-sm float-end" title="Help">
                                <span aria-hidden="true" class="mdi mdi-help-circle"></span>
                                <span class="visually-hidden">Help</span>
                            </a>
                        {% endif %}
                        {% block title %}{% if editing %}Editing {{ obj_type }} {{ obj }}{% else %}Add a new:{% endif %}{% endblock %}
                    </h3>
                    {% block form %}
                        {% block form_fields %}
                            {% render_form form %}
                        {% endblock %}
                    {% endblock %}
                    <div class="gap-8 hstack justify-content-center">
                        {% block buttons %}
                            {% if editing %}
                                <button type="submit" name="_update" class="btn btn-primary">Update</button>
                            {% else %}
                                <button type="submit" name="_create" class="btn btn-primary">Create</button>
                            {% endif %}
                            <button type="button" class="btn btn-secondary" data-bs-dismiss="modal" aria-label="Close">Cancel</button>
                        {% endblock %}
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
